from common.ds_create_headers import CreateHeaders
from common.ds_base_api import CommonRequest
from common.ds_process_test_cases import ProcessJson
import os

class AgainRun:

    def __init__(self):
        self.create_headers = CreateHeaders()
        self.common_request = CommonRequest()
        self.process_json = ProcessJson()

    def again_run(self):
        self.create_headers.write_store_id()
        self.create_headers.write_user_token()
        case_count = self.process_json.get_case_count()
        url_list = self.process_json.get_case_url()
        method_list = self.process_json.get_case_method()
        data_list = self.process_json.get_case_data()
        headers = self.create_headers.get_request_headers()
        print(headers)
        if len(url_list) != case_count or len(method_list) != case_count:
            print('测试用例数据不正确')
        else:
            for url in url_list:
                for method in method_list:
                    for data in data_list:
                        if data == {}:
                            data = None
                            response = self.common_request.choose_method(url=url, method=method, data=data, headers=headers)
                            return response


if __name__ == '__main__':
    run = AgainRun()
    print(run.again_run())